

<div id="main" role="main">
	<div class="tab-content tab-addtabs">
		<div id="content">
			<div class="row">
				<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
					 <div class="content">
						<form class="layui-form" >
							<div class="layui-form-item">
								<label class="layui-form-label">岗位名称：</label>
								<div class="layui-input-block">
									<input type="text" id="name" placeholder="岗位名称" class="layui-input" value="{$info.j_name}">
								</div>
							</div>
								
							<div class="layui-form-item">
								<label class="layui-form-label">上级岗位：</label>
								<div class="layui-input-block" id="pid" data-id="{$info.j_pid}">
									<input type="text" value="{$name}" disabled class="layui-input">
								</div>
							</div>
							
							<div class="layui-form-item">
								<label class="layui-form-label">公共角色：</label>
								<div class="layui-input-block">
									{volist name="role" id="v"}
									<input type="checkbox" name="role" title="{$v.r_name}" value="{$v.r_id}" lay-skin="primary" {if condition="in_array($v['r_id'], $array)"}checked{/if}>
									{/volist}
								</div>
							</div>

						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>


<script>
layui.use(['form'], function(){
var form = layui.form;
});

function doSubimt() {
var res;
var name        = $('#name').val();
var pid         = $('#pid').attr('data-id');
var role        = [];
$('input[name="role"]:checked').each(function(){ 
	role.push($(this).val()); 
}); 

var data        = {'id':{$id}, 'name':name,'pid':pid,'role':JSON.stringify(role)};
if (name == '') {
	$.thinkmimi({Content : '岗位名称不能为空！', Type:2, Align:'right', OutTime:2000});return false;
}
if (!role) {
	$.thinkmimi({Content : '请选择对应的角色！', Type:2, Align:'right', OutTime:2000});return false;
}
$.ajax({
	type: 'post',
	data: data,
	async: false,
	url: "{:url('upd')}",
	success: function(data) {
		var array = eval('('+data+')');
		res = array;
		if (array['code'] == '01') {
			$.thinkmimi({Content : array['msg'], Type:2, Align:'right', OutTime:2000});
			res = false;
		}
	}
});
return res;
}
</script>